# Maintainer: Antoni Aloy <aaloytorrens@gmail.com>
pkgname=gzdoom
pkgver=4.11.3
pkgrel=0
pkgdesc="Feature centric port for all Doom engine games"
url="https://www.zdoom.org/"
# ppc64le blocked by zmusic
# x86 blocked by sse2
# riscv64 fails to build, link-make applet not found
# 32-bit builds blocked by src/common/engine/i_interface.cpp:4:29 (error: static assertion failed: 32 builds are not supported)
# s390x: mainframe
arch="aarch64 x86_64"
license="GPL-3.0-or-later"
depends="
	fluidsynth
	libwebpdemux
	libwebpmux
	"
makedepends="
	bzip2-dev
	cmake
	gtk+3.0-dev
	libgme-dev
	libjpeg-turbo-dev
	libsndfile-dev
	libvpx-dev
	libwebp-dev
	mesa-dev
	mpg123-dev
	musl-fts-dev
	nasm
	openal-soft-dev
	samurai
	sdl2-dev
	vulkan-loader-dev
	zlib-dev
	zmusic-dev
	"
subpackages="$pkgname-doc"

source="
	https://github.com/coelckers/gzdoom/archive/refs/tags/g$pkgver.tar.gz
	0001-link-zipdir-against-fts.patch
	0002-fix-musl-fts.patch
	0003-define-cpu_set_t.patch
	no-execinfo.patch
	force-include-order.patch
	cmake-version.patch
	"
builddir="$srcdir/$pkgname-g$pkgver"
options="!check" # No test suite

build() {
	if [ "$CBUILD" != "$CHOST" ]; then
		CMAKE_CROSSOPTS="-DCMAKE_SYSTEM_NAME=Linux -DCMAKE_HOST_SYSTEM_NAME=Linux"
	fi
	cmake -B build -G Ninja \
		-DCMAKE_BUILD_TYPE=Release \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DDYN_GTK=OFF \
		-DDYN_OPENAL=OFF \
		-DALPINE_PKGVER="$pkgver" \
		$CMAKE_CROSSOPTS
	cmake --build build
}

package() {
	DESTDIR="$pkgdir" cmake --install build
}

sha512sums="
0abe69f85e2f0946e92d6ae2bbc4710c1e184a6748d4ef8a5f0c0daf31b67779b9085154877467144da650314e6c8dcde429cd47db06b17ec1ea66c63759568d  g4.11.3.tar.gz
137d3211cdae714499bc5e99017f5d51f491416ac2ce41c9f67ad4b76ca3c74a3b801321c79229a4e69fe60796d9d9daf3e7d579e2499417d193745c4d95f64a  0001-link-zipdir-against-fts.patch
c7096ade84a73d8813af70ad0aad90d4f057a9027fd8bb368091bac66323b59090c8f3da74821aae86e86eae7771d441b8f7dd299448d85c03e39ef5c4bcf419  0002-fix-musl-fts.patch
5e8558b87c62a65073da5a42f284cc733430b71bbd20e0d3c59286e4e26371d745ca6f63cca7ada3930680efcf3599c185d8f5d074102af55ae67cbe02f31268  0003-define-cpu_set_t.patch
db1166ba7561fb560a67797764c715b124d8cf39f9c251d3dbdd1f42b34257144c5d7873796d1c6cfa13be5dc11860e325527b7019f186fac1f7cd9c0c48ef8b  no-execinfo.patch
6b6eef6aa46aa3a065567f93165960bf6894dd7b0ea0b2f184772b985c4b3612d5863499f683fecf6f5977178c62e38218abd7bc288947b3d31461a8f935e9e9  force-include-order.patch
be700d296aebfbd26d280eaae6192788915c3fc13fb87b49e68512b6aa8cfddd41132c6f694086d872ba886e0853f3cbf182d7b8871296f1c663623aac919cba  cmake-version.patch
"
